<!DOCTYPE html>
<html>

<head>
  <title></title>
</head>

<body>
  <video id="player" controls></video>
  <input type="file" id="uploader">
  <script src="./ffmpeg.min.js"></script>
  <script>
    const { createFFmpeg, fetchFile } = FFmpeg;
    const ffmpeg = createFFmpeg({ log: true });
    const transcode = async ({ target: { files } }) => {
      const { name } = files[0];
      await ffmpeg.load();
      const file = await fetchFile(files[0]);
      console.log(file);
      ffmpeg.FS('writeFile', name, await fetchFile(files[0]));
      await ffmpeg.run('-i', name, 'output.mp4');
      const data = ffmpeg.FS('readFile', 'output.mp4');
      const video = document.getElementById('player');
      video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
      video.play();
    }
    document
      .getElementById('uploader').addEventListener('change', transcode);
  </script>
</body>

</html>